<extend name="Public/base" />
<block name="content">
<!-- 配置文件 -->
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.js"></script>
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a href="{:U('Index/index')}" title="首页" class="tip-bottom"><i class="icon-home"></i> 首页</a> <a href="#" class="current">{$meta_title}</a>
		</div>
	</div>
	<div class="container-fluid">
		<br/>
			<a class="btn btn-warning" href="{$back_url}">返 回</a>
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-content ">
						<form action="#" method="get" class="form-horizontal" autocomplete="off">
							<div class="control-group">
								<label class="control-label">活动模板 :</label>
								<div class="controls">
									<input type="text" class="ui-wizard-content span3" value="{$activity_theme|htmlspecialchars}" disabled />
								</div>
								
								<if condition="$info neq null">
									<label class="control-label">模块位置/字符 :</label>
									<div class="controls">
										<input type="text" class="ui-wizard-content span1" value="位置：{$info.position}" disabled />
										<input type="text" class="ui-wizard-content span2" value="<jjhh>{$info.position}</jjhh>" disabled />
									</div>
								<else/>
									<label class="control-label">模块位置 :</label>
									<div class="controls" style="height:30px;">
										<select class="form-control span2" name="position" class="span1" disabled >
											<option value=0>模块位置</option>
											<volist name="position" id="vo">
												<option value='{$vo.position}'>{$vo.position}</option>
											</volist>
										</select>
									</div>
								</if>
								
								
								<label class="control-label">模板有效时间 :</label>
								<div class="controls">
									<input type="text" class="ui-wizard-content" style="width:120px;" value="{:time_format($time['start_time'],'Y-m-d H:i')}" disabled /> － <input type="text" style="width:120px;" class="ui-wizard-content" value="{:time_format($time['end_time'],'Y-m-d H:i')}" disabled />
								</div>
								
								<label class="control-label">模块名称 :</label>
								<div class="controls">
									<input type="text" name="module_name" class="ui-wizard-content span3" value="{$info.module_name|htmlspecialchars}" />
								</div>
								<label class="control-label">展示时间 :</label>
								<div class="controls">
									<input type="text" placeholder="展示时间" name="start_time" class="datepicker" style="width:150px;" value='<gt name="info.start_time" value="0">{:time_format($info["start_time"],"Y-m-d H:i")}</gt>'>
								</div>
								<label class="control-label">结束时间 :</label>
								<div class="controls">
									<input type="text" placeholder="结束时间" name="end_time" class="datepicker" style="width:150px;" value='<gt name="info.end_time" value="0">{:time_format($info["end_time"],"Y-m-d H:i")}</gt>' >
								</div>
								
								
								
							</div>
							
							<div class="control-group">
								<label class="control-label">模板内容 :</label>
								<div class="controls">
									<!-- 加载编辑器的容器 -->
								    <textarea id="container" name="content" type="text/plain" style="width:100%">{$info.module_content}</textarea>
								</div>
							</div>
							
							<div class="controls">
								<button type="button" id="submit" class="btn btn-success">提 交</button>
								<if condition="$info neq null">
									<input type="hidden" value="{$info.activity_module_id}" name="activity_module_id">
									<input type="hidden" value="{$info.activity_id}" name="activity_id">
									<input type="hidden" value="{$info.theme_id}" name="theme_id">
								<else/>
									<input type="hidden" value="{$activity_id}" name="activity_id">
									<input type="hidden" value="{$theme_id}" name="theme_id">
								</if>
								<input type="hidden" value="{$info.position}" name="position" id="position_id">
								<input type="hidden" value="{$back_url}" name="url">
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(function(){
	//日期控件
	$(".datepicker").datetimepicker({
		format: 'yyyy-mm-dd hh:ii', 
	  	//weekStart: 1, 
	  	startDate:'{:time_format($time["start_time"],"Y-m-d H:i")}', //开始时间，在这时间之前都不可选
	    endDate:'{:time_format($time["end_time"],"Y-m-d H:i")}',//结束时间，在这时间之后都不可选
	    autoclose: true,
	    todayBtn: true
	});
	//ueditor
	var ue = UE.getEditor('container',{
	    allowDivTransToP: false,
	    initialFrameHeight: 300,
	    toolbars: [
			['fullscreen', 'source', 'undo', 'redo', 'bold', 'italic', 'underline', 'fontborder', 'backcolor', 'fontsize', 'fontfamily', 'justifyleft', 'justifyright', 'justifycenter', 'justifyjustify', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', 'link', 'unlink']
		]
	});
	$("#submit").click(function(){
		//锁定提交按钮
		$(this).attr('disabled',true);
		//编辑器HTML切换
		$('#edui4_body').trigger('click');
		var self = $('form');
		$.post("{:U('Activity/activityThemeModuleEdit')}", self.serialize(), call_back, "json");
		return false;
		/**
		 * @todo 接收返回值
		 */
		function call_back(data){
			if(data.status == 1){
				tke_alert(data.info,'alert-success');
				setTimeout(function(){
					location.href = data.url + '#{:NOW_TIME}';
				},1000);
			} else {
				tke_alert(data.info,'alert-error');
				$("#submit").attr('disabled',false);
			}
		}
	});
	<if condition="$position_id neq 0">
		set_value("position","{$position_id}");
		$('#position_id').val('{$position_id}');
	</if>
});
//导航高亮
highlight_subnav("{:U('Activity/activityThemeModule')}");
</script>
</block>